/**
 * Copyright (C) 2010 altuure <altuure [AT] gmail [DOT] com> http://www.altuure.com/projects/yagdao
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.altuure.yagdao.grammar;

import com.altuure.yagdao.grammar.YagdaoParser.condition_col_return;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.tree.CommonTree;
import org.junit.Assert;
import org.junit.Test;

public class ConditionColumn {
   
    @Test
    public void testGT() throws RecognitionException {
        testResultList( "abc >");
    }
    @Test
    public void testGE() throws RecognitionException {
        testResultList( "Abd >=");
    }
    @Test
    public void testLT() throws RecognitionException {
        testResultList( "abc<");
    }
    @Test
    public void testLE() throws RecognitionException {
        testResultList( "dd>");
    }
    @Test
    public void testEQ() throws RecognitionException {
        testResultList( "dddd=");
        testResultList( "dddd==");
    }
    @Test
    public void testNOTEQ() throws RecognitionException {
        testResultList( "dddd<>");
    }
    @Test
    public void testIsNull() throws RecognitionException {
        testResultList( "dddd is null");
        testResultList( "pstring is null");
    }
    @Test
    public void testIsNotNull() throws RecognitionException {
        testResultList( "dddd is not null");
    }
    @Test
    public void testLike() throws RecognitionException {
        testResultList( "dddd is not null");
    }
    @Test
    public void testILike() throws RecognitionException {
        testResultList( "dddd is not null");
    }
    @Test
    public void testBetween() throws RecognitionException {
        testResultList( "dddd between ");
    }
    @Test
    public void testIn() throws RecognitionException {
        testResultList( "dddd in ");
    }
    @Test
    public void testNotIn() throws RecognitionException {
        testResultList( "dddd not in ");
    }
    @Test
    public void testfunction() throws RecognitionException {
        testResultList( "dddd<>currenttime()");
    }
    /**
     * @param input
     * @throws RecognitionException
     */
    public void testResultList(String input) throws RecognitionException {
        ANTLRStringStream stringStream = new ANTLRStringStream(input);
        final YagdaoLexer lexer = new YagdaoLexer(stringStream);
        YagdaoParser parser = new YagdaoParser(new CommonTokenStream(lexer));

         condition_col_return result = parser.condition_col();
         System.out.println("DONE:"+input);
         CommonTree tree = (CommonTree)result.getTree();
         Assert.assertTrue(parser.getErrors().isEmpty());
        System.out.println("DONE:");
    }
}
